package com.gao.mybatis.parse;

import com.gao.mybatis.configuration.Configuration;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.Namespace;
import org.dom4j.io.SAXReader;

import javax.lang.model.element.VariableElement;
import java.io.InputStream;
import java.util.List;

/**
 * <p></p>
 *
 * @author GaoShuangWen
 * @since 2020-03-28 22:35
 */
public abstract class XmlParser implements Parser<Configuration,InputStream> {

    private Configuration configuration;

    public XmlParser(Configuration configuration) {
        this.configuration = configuration;
    }
    @Override
    public Configuration parse(InputStream inputStream) throws Exception {
        SAXReader reader = new SAXReader();
        Document read;
        read = reader.read(inputStream);
        Element rootElement = read.getRootElement();
        return doParse(rootElement,configuration);
    }

     abstract Configuration doParse(Element rootElement,Configuration configuration) throws Exception;
}
